package cn.tedu.mall.product.controller;

import cn.tedu.mall.common.pojo.product.dto.PictureAddNewDTO;
import cn.tedu.mall.common.pojo.product.vo.PictureStandardVO;
import cn.tedu.mall.common.restful.JsonPage;
import cn.tedu.mall.common.restful.JsonResult;
import cn.tedu.mall.product.service.IPictureService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@Api(tags = "图片管理")
@RequestMapping("/pms/pictures")

public class PictureController {
    @Autowired
    IPictureService pictureService;
    @ApiOperationSupport(order = 1006)
    @ApiOperation(value = "查询照片")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页码", dataType = "int"),
            @ApiImplicitParam(name = "pageSize", value = "每页记录数", dataType = "int")
    })
  //sonPage<PictureStandardVO> listByAlbumId(Long albumId, Integer pageNum, Integer pageSize);
    @GetMapping("")
    public JsonResult<JsonPage<PictureStandardVO>>  listPicture( @RequestParam(required = false, defaultValue = "1") Integer pageNum,
                                                                 @RequestParam(required = false, defaultValue = "5")Integer  pageSize,Long albumId){
        JsonPage<PictureStandardVO> pictureStandardVOJsonPage = pictureService.listByAlbumId(albumId, pageNum, pageSize);
        return JsonResult.ok(pictureStandardVOJsonPage);

    }

    @PostMapping("/addnew")
    public  JsonResult<Void>  addPicture(@Valid PictureAddNewDTO pictureAddNewDTO){
        pictureService.addNew(pictureAddNewDTO);
        return JsonResult.ok();
    }
    //编辑图片
    //编辑前先查询

//    @GetMapping("selec/{id}")
//    public  JsonResult<PictureStandardVO>   getPicture (@PathVariable Long  pictureId){
//        pictureService.
//    }










}
